package org.link.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * 
 * project_name:hibernate_annotation
 * package_name:org.link.util
 * file_name:HibernateUtil.java
 * @author Link
 * create_date:2015年12月15日 上午9:20:38
 * modified_date:
 * description:
 *
 */
public class HibernateUtil {

	public static SessionFactory getSessionFactory(){
		Configuration configuration = new Configuration().configure();
		return configuration.buildSessionFactory();
	}
	
	public static Session getSession(){
		return getSessionFactory().openSession();
	}
	
	public static void closeSession(Session session){
		if(session!=null){
			session.close();
		}
	}
	
}
